import 'package:flutter/material.dart';
import 'package:flutter_taotaoshipin/app/app_controller.dart';
import 'package:flutter_taotaoshipin/common/theme/app_colors.dart';
import 'package:get/get.dart';

import 'top_purchase_controller.dart';

class TopPurchasePage extends StatefulWidget {
  const TopPurchasePage({Key? key}) : super(key: key);

  @override
  State<TopPurchasePage> createState() => _TopPurchasePageState();
}

class _TopPurchasePageState extends State<TopPurchasePage> {
  @override
  void dispose() {
    Get.delete<TopPurchaseController>();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final controller = Get.find<TopPurchaseController>();
    final state = Get.find<TopPurchaseController>().state;

    AppController appController = Get.find();
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        InkWell(
          onTap: () {
            controller.watchAdToUnlock();
          },
          child: Container(
            width: 300,
            height: 60,
            decoration: BoxDecoration(
              color: AppColors.app_main,
              borderRadius: BorderRadius.circular(50),
            ),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Icon(
                  Icons.play_circle,
                  color: Colors.white,
                  size: 35,
                ),
                Text(
                  '看广告解锁${state.sort}-${state.sort + appController.csj.num! - 1}集',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 20,
                    letterSpacing: 2,
                  ),
                ),
              ],
            ),
          ),
        ),
        SizedBox(height: 35),
        InkWell(
          onTap: () {
            controller.showTipsAndPay();
          },
          child: Container(
            width: 300,
            height: 60,
            decoration: BoxDecoration(
              color: AppColors.app_main,
              borderRadius: BorderRadius.circular(50),
            ),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                  '开通会员免广告',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 20,
                    letterSpacing: 2,
                  ),
                ),
              ],
            ),
          ),
        ),
      ],
    );
  }
}
